package cn.iocoder.yudao.module.nmkj.controller.app.culture;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.culture.vo.CulturePageReqVO;
import cn.iocoder.yudao.module.nmkj.controller.admin.culture.vo.CultureRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.culture.CultureDO;
import cn.iocoder.yudao.module.nmkj.service.culture.CultureService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 企业文化")
@RestController
@RequestMapping("/nmkj/culture")
@Validated
public class AppCultureController {

    @Resource
    private CultureService cultureService;

    @GetMapping("/page")
    @Operation(summary = "获得企业文化分页")
    public CommonResult<PageResult<CultureRespVO>> getCulturePage(@Valid CulturePageReqVO pageReqVO) {
        pageReqVO.setStatus(1); //用户端只允许请求开启状态数据
        PageResult<CultureDO> pageResult = cultureService.getCulturePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, CultureRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得企业文化列表")
    public CommonResult<List<CultureRespVO>> getCultureList(@Valid CulturePageReqVO reqVO) {
        reqVO.setStatus(1); //用户端只允许请求开启状态数据
        List<CultureDO> listesult = cultureService.getCultureList(reqVO);
        return success(BeanUtils.toBean(listesult, CultureRespVO.class));
    }

}
